import { Component, OnInit } from '@angular/core';
// import { Recharge } from '../../interfaces/recharge.interfaces';
import { ModalService, Pagination } from 'ng-tui';
// import { ManageService } from '../../services/job.service';
import { GlobalService, AuthService } from '../../../../cores/services';
import { HttpConfig } from '../../../../configs/http.config';
import { ApiData, SearchParams } from '../../../../cores/classes';
import { Goods } from './../../interfaces/manage.interface';
import { ManageService } from '../../services/manage.service';

@Component({
    template: `
    <div class="modal-content">
    <div class="modal-header">
        <h5 class="modal-title">添加区域</h5>
        <button (click)="modal.dismiss()" type="button" class="close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div style="border-top: 3px solid #387ddd !important;width: 75px;margin-left: 20px;"></div>
    <div class="modal-body">

        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">国家</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.country" placeholder="请输入国家关键词">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">省</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.province" placeholder="请输入省关键词">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">市</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.city" placeholder="请输入市关键词">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">区</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.county" placeholder="请输入区关键词">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">详细地址</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.address" placeholder="请输入详细地址">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">区域名称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.areaName" placeholder="请输入区域名称">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">区域编号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="goods.areaNumber" placeholder="请输入区域编号">
            </div>
        </div>

    </div>
    <div class="modal-footer" style="justify-content: center; ">
        <button (click)="modal.dismiss()" type="button" class="btn" style="background-color: #eaf4ff;
    border-color: #dae0e5;color: #000;width: 18%;margin-right: 1.25rem;">取消</button>
        <button tsBtn loading (submit)="confirmSave($event)" style="background-color: #387ddd;width: 18%;
    border-color: #387ddd;" color="success">保存</button>
    </div>
</div>`,
})
export class ModalComponent {
    getlist = new Array<any>();
    getlista = new Array<any>();
    conpay = new Array<any>();
    pagination = new Pagination();
    search = new SearchParams({ status: '', uid: '', orderSn: '' });

    loading = false;
    selectValue = 1;
    uploading = false;
    userInfo: any;
    goods: Goods = {};
    listShoper = new Array<any>();

    constructor(
        public global: GlobalService,
        private modal: ModalService,
        private manageService: ManageService,
        private auth: AuthService,
    ) {
    }
    /**
     * 职位增删
     * @param btn
     */
    confirmSave(btn: any) {
        (this.goods.id > 0 ? this.manageService.updateGoods(this.goods) : this.manageService.insertGoods(this.goods))
            .subscribe({
                next: () => this.modal.close(),
                complete: () => btn.dismiss()
            });
    }


}
